using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace FastFoodToNight.Models.Mapping
{
    public class HinhAnhMap : EntityTypeConfiguration<HinhAnh>
    {
        public HinhAnhMap()
        {
            // Primary Key
            this.HasKey(t => t.mahinh);

            // Properties
            this.Property(t => t.tenhinh)
                .HasMaxLength(100);

            // Table & Column Mappings
            this.ToTable("HinhAnh");
            this.Property(t => t.mahinh).HasColumnName("mahinh");
            this.Property(t => t.tenhinh).HasColumnName("tenhinh");
            this.Property(t => t.khoa).HasColumnName("khoa");
            this.Property(t => t.masanpham).HasColumnName("masanpham");

            // Relationships
            this.HasOptional(t => t.SanPham)
                .WithMany(t => t.HinhAnhs)
                .HasForeignKey(d => d.masanpham);

        }
    }
}
